import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

import { GetEnterpriseCategory, Scenes } from '../Common/Conversion'

export const Enterprise = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`getEnterpriseOrganizationConstrained`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        hideInSearch: true,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '企业名称' },
            { ...commonTableList.code, rules: true },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'enterpriseCategoryUuid',
                title: '企业分类',
                valueType: 'select',
                valueEnum: await GetEnterpriseCategory(),
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'enterpriseLevel',
                title: '企业评级',
                valueType: 'inputNumber',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'sceneUuid',
                title: '项目场景',
                valueType: 'select',
                valueEnum: await Scenes(),
                rules: true,
                ellipsis: true,
                width: 300,
                hideInSearch: true,
            },

            {
                dataIndex: 'legalPerson',
                title: '企业法人',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'sales',
                title: '销售及联系方式',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'website',
                title: '网址官网',
                valueType: 'input',
                ellipsis: true,
                width: 300,
            },
            {
                dataIndex: 'capacity',
                title: '集料产量',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'manufacturing',
                title: '生产工艺',
                valueType: 'input',
                ellipsis: true,
                width: 300,
            },
            {
                dataIndex: 'address',
                title: '料厂地址',
                valueType: 'input',
                ellipsis: true,
                width: 300,
            },
            {
                dataIndex: 'miningMode',
                title: '开采方式',
                valueType: 'input',
                width: 300,
            },
            {
                dataIndex: 'license',
                title: '许可证',
                valueType: 'input',
                width: 300,
            },
            {
                dataIndex: 'lng',
                title: '经度',
                valueType: 'input',
                width: 300,
            },
            {
                dataIndex: 'lat',
                title: '纬度',
                valueType: 'input',
                width: 300,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,

                        <OpenTwoRouter
                            key="Two"
                            title="企业文件"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'EnterpriseFiles',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                                type: 'security',
                            }}
                        />,
                        <OpenTwoRouter
                            key="One"
                            title="企业图集"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'EnterpriseImage',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                                type: 'security',
                            }}
                        />,

                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
